main() {
  fun("张三", 18);
  fun2("李四", null);
  fun2("王五", 20);
  fun3("李四");
  fun3("王五", 20);
  fun4("赵六", age: 18, height: 180);
  fun4("孙七", height: 180);
  fun4("周八");
  fun4("吴九", age: 18);
}

//必传参数
void fun(String name, int age) {
  print("name: $name, age: $age");
}

//可选参数,可以传也可以不传,age为空时,不传年龄(需要传递一个null)
void fun2(String name, int? age) {
  if (age != null) {
    print("name: $name, age: $age");
  } else {
    print("name: $name");
  }
}

//可选参数,可以传也可以不传,默认值为18
void fun3(String name, [int age = 18]) {
  print("name: $name, age: $age");
}

//可选命名参数
void fun4(String name, {int? age, int? height}) {
  print("name: $name, age: $age, height: $height");
}
